package com.hao.tool.web.module.base.controller;

import cn.hutool.extra.qrcode.QrCodeUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;

/**
 * description
 *
 * @author RuiHaoZ on GZ.cmhk
 * @date 2019-11-22 23:37
 */
@RestController
@RequestMapping("/rest/base")
public class BaseRestController {

    @GetMapping("/qr")
    public void buildQr(String content, HttpServletResponse response) {
        byte[] bytes = QrCodeUtil.generatePng(content, 300, 300);
        OutputStream outputStream = null;
        try {
            outputStream = response.getOutputStream();
            outputStream.write(bytes);
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
        }
    }
}
